/** 
 * @properties={typeid:24,uuid:"ADEF8A5B-569A-469F-972E-9176D5489693"}
 * @AllowToRunInFind
 */
function buscar_pendientes() 
{	
	// en el select se debe poner el id de la tabla
	var query 	= 'SELECT ctacte_pr_id FROM ctacte_pr "cc" WHERE proveedor_id = '+globals.gProveedorDesde+' and importe = saldo';
	var ds		= databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()),query,null,-1);
	controller.loadRecords(ds);
	var found = ds.getMaxRowIndex();
	if (found == 0)
	{
		globals.DIALOGS.showWarningDialog('Aviso','No hay movimientos pendientes','OK');
		return;
	}
}

/**
 * @properties={typeid:24,uuid:"EAE41F5E-6340-4A69-AC4C-A8011D67A594"}
 */
function Iniciar()
{
	globals.gProveedorDesde = null;
	globals.marca_primer_find = 1;
	controller.loadRecords(0);
	return true
}

/**
 * @properties={typeid:24,uuid:"90A6AD6B-0D4D-4428-8F16-FD8479E5ECEC"}
 */
function confirmar_seleccion() 
{
	var found = databaseManager.getFoundSetCount(foundset)
	if (found > 0)
	{ //borrar lo marcado en ctacte
		var i = found;
		while (i > 0)
		{	//recorrer los marcados = 1
			var $rcd = foundset.getRecord(i)
			if ($rcd.marcado_ctacte == 1)
			{
				if ($rcd.importe == $rcd.saldo)
				{
					controller.deleteRecord();
				}
			}
			i--;
		} // fin del while  
	} // fin del if	
}

/**
 * @properties={typeid:24,uuid:"B53EA4B8-B110-446C-B8C6-3DEFB1D7F72E"}
 */
function marcar_todo() 
{
	var $cant = databaseManager.getFoundSetCount(foundset)
	for (var i = 1 ; i <= $cant ; i++)
	{		 
		var $rcd = foundset.getRecord(i)
		$rcd.marcado_ctacte = 1
	}
}

/**
 * @properties={typeid:24,uuid:"9FDD387E-ABC2-4FA3-B40C-4D924CE3DE9F"}
 */
function desmarcar_todo() 
{
	var $cant = databaseManager.getFoundSetCount(foundset)
	for (var i = 1 ; i <= $cant ; i++)
	{		 
		var $rcd = foundset.getRecord(i)
		$rcd.marcado_ctacte = 0
	}
}